package com.sx.micowell.framework.model

import android.text.TextUtils
import androidx.databinding.ObservableField
import com.example.mvvm.base.vm.BaseViewModel
import com.example.mvvm.until.LogUtils
import com.example.mvvm.until.ToastUtils
import com.sx.micowell.framework.arouth.RouteManager
import com.sx.micowell.framework.binding.BindingCommand
import com.sx.micowell.framework.binding.impl.IBindingAction

/**
 * @author: YY
 * @time: 2021/8/3
 * @describe TODO
 */
class RegisterModel : BaseViewModel() {

    // 手机号码
    var phoneNumber = ObservableField("")

    // 类型 0 注册 1 重置密码
    var type : Int = 0

    //输入手机号
    var phoneNumberOnTextChangeCommand: BindingCommand<String> = BindingCommand {s ->
        LogUtils.d("phoneNumberOnTextChangeCommand: $s")
        phoneNumber.set(s)
    }

    // 下一步
    val nextStepOnClickCommand = BindingCommand<Any>(IBindingAction {
        if (TextUtils.isEmpty(phoneNumber.get())) {
            ToastUtils.showShort("请输入手机号")
        } else {
            RouteManager.getInstance().intentVerifyCode(phoneNumber.get().toString(), type)
        }
    })

}